######################################################################################
###Data setup: mean imputation for baseline values of outcomes
######################################################################################

#Satisfaction with RS Info from UWA
M$b.knowledge.b7 <- ifelse(M$B_satisfied_with_UWA_info_on_RS=="very_dissatisf", 1, M$B_satisfied_with_UWA_info_on_RS)
M$b.knowledge.b7 <- ifelse(M$b.knowledge.b7=="somewhat_dissa", 2, M$b.knowledge.b7)
M$b.knowledge.b7 <- ifelse(M$b.knowledge.b7=="neutral", 3, M$b.knowledge.b7)
M$b.knowledge.b7 <- ifelse(M$b.knowledge.b7=="somewhat_satis", 4, M$b.knowledge.b7)
M$b.knowledge.b7 <- ifelse(M$b.knowledge.b7=="very_satisfied", 5, M$b.knowledge.b7)
M$b.knowledge.b7 <- ifelse(M$b.knowledge.b7 %in% c(1,2,3,4,5), M$b.knowledge.b7, NA)
M$b.knowledge.b7 <- as.numeric(M$b.knowledge.b7)
M <- mean.imp(data=M, var="b.knowledge.b7", cluster="Updated.Village")

M$e.knowledge.b7 <- ifelse(M$E_Satisfied_with_info_by_UWA_on_=="very_dissatisf", 1, M$E_Satisfied_with_info_by_UWA_on_)
M$e.knowledge.b7 <- ifelse(M$e.knowledge.b7=="somewhat_dissa", 2, M$e.knowledge.b7)
M$e.knowledge.b7 <- ifelse(M$e.knowledge.b7=="neutral", 3, M$e.knowledge.b7)
M$e.knowledge.b7 <- ifelse(M$e.knowledge.b7=="somewhat_satis", 4, M$e.knowledge.b7)
M$e.knowledge.b7 <- ifelse(M$e.knowledge.b7=="very_satisfied", 5, M$e.knowledge.b7)
M$e.knowledge.b7 <- ifelse(M$e.knowledge.b7 %in% c(1,2,3,4,5), M$e.knowledge.b7, NA)
M$e.knowledge.b7 <- as.numeric(M$e.knowledge.b7)

#Know How RS Works Generally
M$b.knowledge.b8 <- ifelse(M$B_I_can_explain_how_RS_works=="disagree", 1, M$B_I_can_explain_how_RS_works)
M$b.knowledge.b8 <- ifelse(M$b.knowledge.b8=="somewhat_disag", 2, M$b.knowledge.b8)
M$b.knowledge.b8 <- ifelse(M$b.knowledge.b8=="somewhat_agree", 3, M$b.knowledge.b8)
M$b.knowledge.b8 <- ifelse(M$b.knowledge.b8=="agree", 4, M$b.knowledge.b8)
M$b.knowledge.b8 <- ifelse(M$b.knowledge.b8 %in% c(1,2,3,4), M$b.knowledge.b8, NA)
M$b.knowledge.b8 <- as.numeric(M$b.knowledge.b8)
M <- mean.imp(data=M, var="b.knowledge.b8", cluster="Updated.Village")

M$e.knowledge.b8 <- ifelse(M$E_Can_explain_how_RS_works=="disagree", 1, M$E_Can_explain_how_RS_works)
M$e.knowledge.b8 <- ifelse(M$e.knowledge.b8=="somewhat_disag", 2, M$e.knowledge.b8)
M$e.knowledge.b8 <- ifelse(M$e.knowledge.b8=="somewhat_agree", 3, M$e.knowledge.b8)
M$e.knowledge.b8 <- ifelse(M$e.knowledge.b8=="agree", 4, M$e.knowledge.b8)
M$e.knowledge.b8 <- ifelse(M$e.knowledge.b8 %in% c(1,2,3,4), M$e.knowledge.b8, NA)
M$e.knowledge.b8 <- as.numeric(M$e.knowledge.b8)

#How RS Works in my Village
M$b.knowledge.b9 <- ifelse(M$B_I_can_explain_RS_in_my_village=="disagree", 1, M$B_I_can_explain_RS_in_my_village)
M$b.knowledge.b9 <- ifelse(M$b.knowledge.b9=="somewhat_disag", 2, M$b.knowledge.b9)
M$b.knowledge.b9 <- ifelse(M$b.knowledge.b9=="somewhat_agree", 3, M$b.knowledge.b9)
M$b.knowledge.b9 <- ifelse(M$b.knowledge.b9=="agree", 4, M$b.knowledge.b9)
M$b.knowledge.b9 <- ifelse(M$b.knowledge.b9 %in% c(1,2,3,4), M$b.knowledge.b9, NA)
M$b.knowledge.b9 <- as.numeric(M$b.knowledge.b9)
M <- mean.imp(data=M, var="b.knowledge.b9", cluster="Updated.Village")

M$e.knowledge.b9 <- ifelse(M$E_Can_explain_RS_in_village=="disagree", 1, M$E_Can_explain_RS_in_village)
M$e.knowledge.b9 <- ifelse(M$e.knowledge.b9=="somewhat_disag", 2, M$e.knowledge.b9)
M$e.knowledge.b9 <- ifelse(M$e.knowledge.b9=="somewhat_agree", 3, M$e.knowledge.b9)
M$e.knowledge.b9 <- ifelse(M$e.knowledge.b9=="agree", 4, M$e.knowledge.b9)
M$e.knowledge.b9 <- ifelse(M$e.knowledge.b9 %in% c(1,2,3,4), M$e.knowledge.b9, NA)
M$e.knowledge.b9 <- as.numeric(M$e.knowledge.b9)

#Opportunities to Participate in Planning
M$b.participate.b10 <- ifelse(M$B_10_how_much_do_you_agree_or_disagree_with_the_following_statement_people_like_me_have_opportunities_to_participate_in_the_planning_of_the_revenue_sharing_program_for_my_village_=="disagree", 1, M$B_10_how_much_do_you_agree_or_disagree_with_the_following_statement_people_like_me_have_opportunities_to_participate_in_the_planning_of_the_revenue_sharing_program_for_my_village_)
M$b.participate.b10 <- ifelse(M$b.participate.b10=="somewhat_disag", 2, M$b.participate.b10)
M$b.participate.b10 <- ifelse(M$b.participate.b10=="somewhat_agree", 3, M$b.participate.b10)
M$b.participate.b10 <- ifelse(M$b.participate.b10=="agree", 4, M$b.participate.b10)
M$b.participate.b10 <- ifelse(M$b.participate.b10 %in% c(1,2,3,4), M$b.participate.b10, NA)
M$b.participate.b10 <- as.numeric(M$b.participate.b10)
M <- mean.imp(data=M, var="b.participate.b10", cluster="Updated.Village")

M$e.participate.b10 <- ifelse(M$E_Opportunity_to_plan_for_RS=="disagree", 1, M$E_Opportunity_to_plan_for_RS)
M$e.participate.b10 <- ifelse(M$e.participate.b10=="somewhat_disag", 2, M$e.participate.b10)
M$e.participate.b10 <- ifelse(M$e.participate.b10=="somewhat_agree", 3, M$e.participate.b10)
M$e.participate.b10 <- ifelse(M$e.participate.b10=="agree", 4, M$e.participate.b10)
M$e.participate.b10 <- ifelse(M$e.participate.b10 %in% c(1,2,3,4), M$e.participate.b10, NA)
M$e.participate.b10 <- as.numeric(M$e.participate.b10)

#Participate in RS meetings in past months
M$e.participate.e4 <- ifelse(M$E_Participate_in_RS_meetings=="yes", 1, M$E_Participate_in_RS_meetings)
M$e.participate.e4 <- ifelse(M$e.participate.e4=="no", 0, M$e.participate.e4)
M$e.participate.e4 <- ifelse(M$e.participate.e4 %in% c(0,1), M$e.participate.e4, NA)

#Satisfaction with opportunities to communicate with UWA about RS
M$b.participate.b11 <- ifelse(M$B_satisfaction_communicating_UWA=="very_dissatisf", 1, M$B_satisfaction_communicating_UWA)
M$b.participate.b11 <- ifelse(M$b.participate.b11=="somewhat_dissa", 2, M$b.participate.b11)
M$b.participate.b11 <- ifelse(M$b.participate.b11=="neutral", 3, M$b.participate.b11)
M$b.participate.b11 <- ifelse(M$b.participate.b11=="somewhat_satis", 4, M$b.participate.b11)
M$b.participate.b11 <- ifelse(M$b.participate.b11=="very_satisfied", 5, M$b.participate.b11)
M$b.participate.b11 <- ifelse(M$b.participate.b11 %in% c(1,2,3,4,5), M$b.participate.b11, NA)
M$b.participate.b11 <- as.numeric(M$b.participate.b11)
M <- mean.imp(data=M, var="b.participate.b11", cluster="Updated.Village")

M$e.participate.b11 <- ifelse(M$E_Satisfaction_with_communicatio=="very_dissatisf", 1, M$E_Satisfaction_with_communicatio)
M$e.participate.b11 <- ifelse(M$e.participate.b11=="somewhat_dissa", 2, M$e.participate.b11)
M$e.participate.b11 <- ifelse(M$e.participate.b11=="neutral", 3, M$e.participate.b11)
M$e.participate.b11 <- ifelse(M$e.participate.b11=="somewhat_satis", 4, M$e.participate.b11)
M$e.participate.b11 <- ifelse(M$e.participate.b11=="very_satisfied", 5, M$e.participate.b11)
M$e.participate.b11 <- ifelse(M$e.participate.b11 %in% c(1,2,3,4,5), M$e.participate.b11, NA)
M$e.participate.b11 <- as.numeric(M$e.participate.b11)

#Know Right Person to Contact
M$b.participate.b12 <- ifelse(M$B_knowing_credible_RS_contact=="disagree", 1, M$B_knowing_credible_RS_contact)
M$b.participate.b12 <- ifelse(M$b.participate.b12=="somewhat_disag", 2, M$b.participate.b12)
M$b.participate.b12 <- ifelse(M$b.participate.b12=="somewhat_agree", 3, M$b.participate.b12)
M$b.participate.b12 <- ifelse(M$b.participate.b12=="agree", 4, M$b.participate.b12)
M$b.participate.b12 <- ifelse(M$b.participate.b12 %in% c(1,2,3,4), M$b.participate.b12, NA)
M$b.participate.b12 <- as.numeric(M$b.participate.b12)
M <- mean.imp(data=M, var="b.participate.b12", cluster="Updated.Village")

M$e.participate.b12 <- ifelse(M$E_Know_contact_for_RS=="disagree", 1, M$E_Know_contact_for_RS)
M$e.participate.b12 <- ifelse(M$e.participate.b12=="somewhat_disag", 2, M$e.participate.b12)
M$e.participate.b12 <- ifelse(M$e.participate.b12=="somewhat_agree", 3, M$e.participate.b12)
M$e.participate.b12 <- ifelse(M$e.participate.b12=="agree", 4, M$e.participate.b12)
M$e.participate.b12 <- ifelse(M$e.participate.b12 %in% c(1,2,3,4), M$e.participate.b12, NA)
M$e.participate.b12 <- as.numeric(M$e.participate.b12)

#Satisfaction with Park Management
M$b.satisfaction.b2 <- ifelse(M$B_satisfaction_with_BNP_manageme=="very_dissatisf", 1, M$B_satisfaction_with_BNP_manageme)
M$b.satisfaction.b2 <- ifelse(M$b.satisfaction.b2=="somewhat_dissa", 2, M$b.satisfaction.b2)
M$b.satisfaction.b2 <- ifelse(M$b.satisfaction.b2=="neutral", 3, M$b.satisfaction.b2)
M$b.satisfaction.b2 <- ifelse(M$b.satisfaction.b2=="somewhat_satis", 4, M$b.satisfaction.b2)
M$b.satisfaction.b2 <- ifelse(M$b.satisfaction.b2=="very_satisfied", 5, M$b.satisfaction.b2)
M$b.satisfaction.b2 <- ifelse(M$b.satisfaction.b2 %in% c(1,2,3,4,5), M$b.satisfaction.b2, NA)
M$b.satisfaction.b2 <- as.numeric(M$b.satisfaction.b2)
M <- mean.imp(data=M, var="b.satisfaction.b2", cluster="Updated.Village")

M$e.satisfaction.b2 <- ifelse(M$E_Satisfied_with_BNP_management=="very_dissatisf", 1, M$E_Satisfied_with_BNP_management)
M$e.satisfaction.b2 <- ifelse(M$e.satisfaction.b2=="somewhat_dissa", 2, M$e.satisfaction.b2)
M$e.satisfaction.b2 <- ifelse(M$e.satisfaction.b2=="neutral", 3, M$e.satisfaction.b2)
M$e.satisfaction.b2 <- ifelse(M$e.satisfaction.b2=="somewhat_satis", 4, M$e.satisfaction.b2)
M$e.satisfaction.b2 <- ifelse(M$e.satisfaction.b2=="very_satisfied", 5, M$e.satisfaction.b2)
M$e.satisfaction.b2 <- ifelse(M$e.satisfaction.b2 %in% c(1,2,3,4,5), M$e.satisfaction.b2, NA)
M$e.satisfaction.b2 <- as.numeric(M$e.satisfaction.b2)

#Satisfaction with RS
M$b.satisfaction.b3 <- ifelse(M$B_3_how_satisfied_are_you_with_the_bwindi_national_park_s_revenue_sharing_program_=="very_dissatisf", 1, M$B_3_how_satisfied_are_you_with_the_bwindi_national_park_s_revenue_sharing_program_)
M$b.satisfaction.b3 <- ifelse(M$b.satisfaction.b3=="somewhat_dissa", 2, M$b.satisfaction.b3)
M$b.satisfaction.b3 <- ifelse(M$b.satisfaction.b3=="neutral", 3, M$b.satisfaction.b3)
M$b.satisfaction.b3 <- ifelse(M$b.satisfaction.b3=="somewhat_satis", 4, M$b.satisfaction.b3)
M$b.satisfaction.b3 <- ifelse(M$b.satisfaction.b3=="very_satisfied", 5, M$b.satisfaction.b3)
M$b.satisfaction.b3 <- ifelse(M$b.satisfaction.b3 %in% c(1,2,3,4,5), M$b.satisfaction.b3, NA)
M$b.satisfaction.b3 <- as.numeric(M$b.satisfaction.b3)
M <- mean.imp(data=M, var="b.satisfaction.b3", cluster="Updated.Village")

M$e.satisfaction.b3 <- ifelse(M$E_Satisfied_with_BNP_RS_program=="very_dissatisf", 1, M$E_Satisfied_with_BNP_RS_program)
M$e.satisfaction.b3 <- ifelse(M$e.satisfaction.b3=="somewhat_dissa", 2, M$e.satisfaction.b3)
M$e.satisfaction.b3 <- ifelse(M$e.satisfaction.b3=="neutral", 3, M$e.satisfaction.b3)
M$e.satisfaction.b3 <- ifelse(M$e.satisfaction.b3=="somewhat_satis", 4, M$e.satisfaction.b3)
M$e.satisfaction.b3 <- ifelse(M$e.satisfaction.b3=="very_satisfied", 5, M$e.satisfaction.b3)
M$e.satisfaction.b3 <- ifelse(M$e.satisfaction.b3 %in% c(1,2,3,4,5), M$e.satisfaction.b3, NA)
M$e.satisfaction.b3 <- as.numeric(M$e.satisfaction.b3)

#Support for Conservation (Importance of Protecting Bwindi)
M$b.conservation.b6 <- ifelse(M$B_6_in_your_opinion_how_important_is_it_to_protect_the_forest_and_wildlife_in_bwindi_national_park_=="not_at_all_imp", 1, M$B_6_in_your_opinion_how_important_is_it_to_protect_the_forest_and_wildlife_in_bwindi_national_park_)
M$b.conservation.b6 <- ifelse(M$b.conservation.b6=="not_very_impor", 2, M$b.conservation.b6)
M$b.conservation.b6 <- ifelse(M$b.conservation.b6=="somewhat_impor", 3, M$b.conservation.b6)
M$b.conservation.b6 <- ifelse(M$b.conservation.b6=="very_important", 4, M$b.conservation.b6)
M$b.conservation.b6 <- ifelse(M$b.conservation.b6 %in% c(1,2,3,4), M$b.conservation.b6, NA)
M$b.conservation.b6 <- as.numeric(M$b.conservation.b6)
M <- mean.imp(data=M, var="b.conservation.b6", cluster="Updated.Village")

M$e.conservation.b6 <- ifelse(M$E_Importance_to_protect_BNP=="not_at_all_impor", 1, M$E_Importance_to_protect_BNP)
M$e.conservation.b6 <- ifelse(M$e.conservation.b6=="not_very_impor", 2, M$e.conservation.b6)
M$e.conservation.b6 <- ifelse(M$e.conservation.b6=="somewhat_impor", 3, M$e.conservation.b6)
M$e.conservation.b6 <- ifelse(M$e.conservation.b6=="very_important", 4, M$e.conservation.b6)
M$e.conservation.b6 <- ifelse(M$e.conservation.b6 %in% c(1,2,3,4), M$e.conservation.b6, NA)
M$e.conservation.b6 <- as.numeric(M$e.conservation.b6)